<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    {{count}}
    <com-a></com-a>
    <com-b></com-b>
  </div>
</body>
<script src="./lib/vue.js"></script>
<script>

  Vue.component('ComA', {
    template: `
      <div>
        <p>{{$root.count}}</p> 
        <button @click='add'>+1</button> 
      </div>
    `,
    methods: {
      add() {
        console.log(this.$root.count)
        this.$root.count += 1;
      }
    }
  })

  Vue.component('ComB', {
    template: `
      <div>
        <p>{{$root.count}}</p> 
        <button @click='add'>+1</button> 
      </div>
    `,
    methods: {
      add() {
        console.log(this.$root.count)
        this.$root.count += 1;
      }
    }
  })

  new Vue({
    el: "#app",
    data: {
      count: 123
    },

  })
</script>

</html>